package watercups.operators;

import templates.Operator;
import watercups.states.WaterCupState;

public class Empty1to2 implements Operator<WaterCupState>{

	public int getOperatorNumber(){
		return 5;
	}
	
	public boolean available(WaterCupState s){
		if(s.getCapacity1()>0 && s.getCapacity2()<4)
			return true;
		else
			return false;
	}
	
	public WaterCupState execute(WaterCupState s){
		int needToTransfer=4-s.getCapacity2();
		int transfered;

		if(needToTransfer<s.getCapacity1())
		transfered=needToTransfer;
		else
		transfered=s.getCapacity1();

		return new WaterCupState(s.getCapacity1()-transfered,s.getCapacity2()+transfered);
		}
		public String toString()
		{
		return "Emptying first cup into second cup";
		}
}
